package empox.pos.operator;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class OperatorAdapter extends BaseAdapter {
	Context con;
	OperatorInfo[] oi;

	public OperatorAdapter(Context mContext) {
		con = mContext;
	}

	public void setValue(OperatorInfo[] mOperatorInfo) {
		oi = mOperatorInfo;
	}

	public int getCount() {
		if (oi == null) {
			return 0;
		}
		return oi.length;
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return position;
	}

	static class SH {
		TextView tv1;
//		TextView tv2;
	}

	public View getView(int position, View convertView, ViewGroup parent) {

		SH sh = new SH();

		if (convertView == null) {
			convertView = new LinearLayout(con);
			((LinearLayout) convertView).setGravity(Gravity.CENTER);

			sh.tv1 = new TextView(con);
			sh.tv1.setWidth(200);
			sh.tv1.setHeight(30);
			sh.tv1.setGravity(Gravity.CENTER);
			((LinearLayout) convertView).addView(sh.tv1);

//			sh.tv2 = new TextView(con);
//			sh.tv2.setWidth(200);
//			sh.tv2.setGravity(Gravity.CENTER);
//			((LinearLayout) convertView).addView(sh.tv2);

			convertView.setTag(sh);
		} else {
			sh = (SH) convertView.getTag();
		}

		sh.tv1.setText(oi[position].userName);
//		sh.tv2.setText(oi[position].userName);
		
		return convertView;
	}

}
